From: Carlhuda Date: Sat, 19 Apr 2014 01:07:51 +0000 (-0700) Subject: Start pulling out the configured paths X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~1112 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/success//%22http:/www.example.com/cgi/success/?a=commitdiff_plain;h=6b44764893af3335298283cc9548cbeec53e4217;p=cargo.git Start pulling out the configured paths --- diff --git a/src/cargo/core/package.rs b/src/cargo/core/package.rs index 7ffd8bfcc..dccc6cf58 100644 --- a/src/cargo/core/package.rs +++ b/src/cargo/core/package.rs @@ -12,7 +12,6 @@ pub struct NameVer { impl NameVer { pub fn new(name: &str, version: &str) -> NameVer { - println!("version: {}", version); NameVer { name: name.to_owned(), version: semver::parse(version.to_owned()).unwrap() } } diff --git a/src/cargo/ops/cargo_compile.rs b/src/cargo/ops/cargo_compile.rs index 1da10a9f5..1f1eef4c4 100644 --- a/src/cargo/ops/cargo_compile.rs +++ b/src/cargo/ops/cargo_compile.rs @@ -19,9 +19,11 @@ use std::vec::Vec; use serialize::{Decodable}; use hammer::{FlagDecoder,FlagConfig,FlagConfiguration,HammerError}; use std::io; +use std::os; use std::io::BufReader; use std::io::process::{Process,ProcessExit,ProcessOutput,InheritFd,ProcessConfig}; use {ToCargoError,CargoResult}; +use util::config::{get_config,all_configs}; #[deriving(Decodable)] struct Options { @@ -34,7 +36,7 @@ impl FlagConfig for Options { pub fn compile() -> CargoResult<()> { let options = try!(flags::()); - let manifest_bytes = try!(read_manifest(options.manifest_path).to_cargo_error(~"Could not read manifest", 1)); + let manifest_bytes = try!(read_manifest(options.manifest_path)); call_rustc(~BufReader::new(manifest_bytes.as_slice())) } @@ -66,6 +68,8 @@ fn exec_tty(program: &str, args: &[~str], input: Option<&mut Reader>) -> CargoRe } fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: |&mut ProcessConfig|) -> CargoResult { + let paths = get_config(os::getcwd(), "source-paths"); + let mut config = ProcessConfig::new(); config.program = program; config.args = args; @@ -73,7 +77,7 @@ fn exec(program: &str, args: &[~str], input: Option<&mut Reader>, configurator: println!("Executing {} {}", program, args); - let mut process = try!(Process::configure(config).to_cargo_error(~"Could not configure process", 1)); + let mut process = try!(Process::configure(config).to_cargo_error(|e: io::IoError| format!("Could not configure process: {}", e), 1)); input.map(|mut reader| io::util::copy(&mut reader, process.stdin.get_mut_ref())); diff --git a/src/cargo/ops/mod.rs b/src/cargo/ops/mod.rs index 93d60da38..2d9e296a3 100644 --- a/src/cargo/ops/mod.rs +++ b/src/cargo/ops/mod.rs @@ -1,4 +1,3 @@ -pub mod path_source; pub mod cargo_compile; pub mod cargo_read_manifest; pub mod cargo_rustc; diff --git a/src/cargo/ops/path_source.rs b/src/cargo/ops/path_source.rs deleted file mode 100644 index 6654c0b42..000000000 --- a/src/cargo/ops/path_source.rs +++ /dev/null @@ -1 +0,0 @@ -struct PathSourceOp; diff --git a/src/cargo/util/config.rs b/src/cargo/util/config.rs index 9f579fb7a..f97385e2b 100644 --- a/src/cargo/util/config.rs +++ b/src/cargo/util/config.rs @@ -1,7 +1,7 @@ extern crate collections; extern crate toml; -use super::super::{CargoResult,ToCargoError}; +use super::super::{CargoResult,ToCargoError,CargoError}; use std::{io,fmt}; #[deriving(Eq,TotalEq,Clone,Encodable,Decodable)] @@ -10,9 +10,15 @@ pub enum Location { Global } +#[deriving(Eq,TotalEq,Clone,Encodable,Decodable,Show)] +enum ConfigValueValue { + String(~str), + List(~[~str]) +} + #[deriving(Eq,TotalEq,Clone,Encodable,Decodable)] pub struct ConfigValue { - value: ~str, + value: ConfigValueValue, path: ~str } @@ -82,8 +88,15 @@ fn extract_config(file: io::fs::File, key: &str) -> CargoResult { let path = try!(file.path().as_str().to_cargo_error(~"", 1)).to_owned(); let mut buf = io::BufferedReader::new(file); let root = try!(toml::parse_from_buffer(&mut buf).to_cargo_error(~"", 1)); - let val = try!(try!(root.lookup(key).to_cargo_error(~"", 1)).get_str().to_cargo_error(~"", 1)); - Ok(ConfigValue{ value: val.to_owned(), path: path }) + let val = try!(root.lookup(key).to_cargo_error(~"", 1)); + + let v = match val { + &toml::String(ref val) => String(val.to_owned()), + &toml::Array(ref val) => List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), + _ => return Err(CargoError::new(~"", 1)) + }; + + Ok(ConfigValue{ value: v, path: path }) } fn extract_all_configs(file: io::fs::File) -> CargoResult> { @@ -96,7 +109,8 @@ fn extract_all_configs(file: io::fs::File) -> CargoResult { map.insert(key.to_owned(), ConfigValue { value: val.to_owned(), path: path.clone() }); } + &toml::String(ref val) => { map.insert(key.to_owned(), ConfigValue { value: String(val.to_owned()), path: path.clone() }); } + &toml::Array(ref val) => { map.insert(key.to_owned(), ConfigValue { value: List(val.iter().map(|s: &toml::Value| s.to_str()).collect()), path: path.clone() }); } _ => () } }